//
//  AudioRecorder.h
//  Huahai
//
//  Created by Fox Guo on 13-8-12.
//
//

#import <Foundation/Foundation.h>

#import <AVFoundation/AVFoundation.h>


#define REPEAT_DETECTING_VOICE  0 //
#define TIMEOUT_RECORD_LESS_ONE_SECOND  1 //second
#define MIN_RECORDING_TIME                       1.0f //second
#define MAX_RECORDING_TIME                          60.0f//second
#define NOTICE_RECORDING_TIME                     50.0f//second


typedef enum
{
    //For Message Status Type.
    RECORD_STOPPED,
    RECORD_STARTED,
    RECORD_PAUSED
}
RECORD_STATUS;
@protocol AudioRecordDelegate;

@interface HOAVAudioRecorder : AVAudioRecorder
{
	//    NSString *_filePath;
	//    NSString *_fileName;
	//    NSString *_wavfilePath;
}

@property(nonatomic, retain)NSString *filePath;
@property(nonatomic, retain)NSString *fileName;
@property(nonatomic, retain)NSString *wavfilePath;
@end


@interface AudioRecorder : NSObject<AVAudioRecorderDelegate>
{
    HOAVAudioRecorder *avRecorder;
    AVAudioSession *session;
    id<AudioRecordDelegate> _delgate;
    NSTimer *recordingTimer;
    BOOL isRecordLessOnSecTimeout;
    NSTimeInterval recordTime;
    RECORD_STATUS recordStatus;
}
- (id)initWithDelegate:(id<AudioRecordDelegate>)delgate;
- (void)startRecord;
- (void)pauseRecord;

- (void)resumeRecord;
- (void)stopRecord;
- (NSTimeInterval)getRecordingTime;
-(void)converttoamr:(BOOL)isSuccessed withFilePath:(NSString *)filePath withFileName:(NSString *)fileName;
@end
@protocol AudioRecordDelegate <NSObject>

- (void)onDetectingVoice:(double)lowPassResults;
-(void)showNotificationForRecordTime:(NSTimeInterval)recordTime;
- (void)onStopRecord:(BOOL)isSuccessed totalTime:(NSTimeInterval)totalTime withFilePath:(NSString *)filePath withFileName:(NSString *)fileName;
- (void)onStartRecord;
- (void)onPaused;
- (void)onResumeRecord;

- (void)onRecordLessOneSecond:(BOOL)displayErrorUI;
- (void)onRecordMoreThanOneMinute;
- (void)onErrorArise:(NSError *)error;

@end